package com.jiyang.jyandroid.test02;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.Toast;

import com.jiyang.jyandroid.BaseActivity;
import com.jiyang.jyandroid.R;

/**
 * Created by jy on 2016/10/24.
 * 实验2-1带图片显示的Toast
 */

public class Two_2Activity extends BaseActivity {

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        LinearLayout linearLayout = new LinearLayout(this);
        Button button = new Button(this);
        button.setText("显示Toast");
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast toast = Toast.makeText(Two_2Activity.this, "带图片显示的Toast", Toast.LENGTH_SHORT);
                ImageView imageView = new ImageView(Two_2Activity.this);
                imageView.setImageResource(R.mipmap.child01);
                toast.setView(imageView);
                toast.show();
            }
        });
        linearLayout.addView(button);
        setContentView(linearLayout);
    }
}
